#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
const int N = 5e4 + 10;
typedef struct
{
	int x, y, z;
}S;
S s[N];
int cmp(S a, S b)
{
	return a.z < b.z;
}
double distance(S a, S b)
{
	return sqrt(pow(abs(a.x - b.x), 2) + pow(abs(a.y - b.y), 2) +
		pow(abs(a.z - b.z), 2));
}
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i].x >> s[i].y >> s[i].z;
	}
	sort(s, s + n, cmp);
	/*for (int i = 0; i < n; i++) {
		cout << s[i].x << " " << s[i].y << " " << s[i].z << endl;
	}*/
	double sum = 0;
	for (int i = 0; i < n - 1; i++) {
		sum += distance(s[i], s[i + 1]);
	}
	cout << fixed << setprecision(3) << sum << endl;
	return 0;
}